gtkgesturezoom: Do not check touchpad phase on generic events
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 10 Jun 2020 12:27:14 +0000 (14:27 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Wed, 10 Jun 2020 12:30:58 +0000 (14:30 +0200)
This gesture handles both individual touch events and touchpad gesture
events, and was checking the touchpad phase in generic code paths. This
is dubious since event methods error out on the wrong GdkEventTypes.

Check the touchpad gesture phase within the branch handling touchpad
events, and make it clear which is the gesture phase of all that we are
ignoring.

Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/2825
gtk/gtkgesturezoom.c

index 83f8e3a276d7b26b6dc11410e8d27110c06355c1..d706b502f3ace664a4b851207532e9715cf4f136 100644 (file)
@@ -94,15 +94,15 @@ _gtk_gesture_zoom_get_distance (GtkGestureZoom *zoom,
     goto out;
 
   last_event = gtk_gesture_get_last_event (gesture, sequences->data);
-  phase = gdk_touchpad_event_get_gesture_phase (last_event);
 
-  if (gdk_event_get_event_type (last_event) == GDK_TOUCHPAD_PINCH &&
-      (phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN ||
-       phase == GDK_TOUCHPAD_GESTURE_PHASE_UPDATE ||
-       phase == GDK_TOUCHPAD_GESTURE_PHASE_END))
+  if (gdk_event_get_event_type (last_event) == GDK_TOUCHPAD_PINCH)
     {
       double scale;
+
       /* Touchpad pinch */
+      phase = gdk_touchpad_event_get_gesture_phase (last_event);
+      if (phase == GDK_TOUCHPAD_GESTURE_PHASE_CANCEL)
+        goto out;
 
       scale = gdk_touchpad_event_get_pinch_scale (last_event);
       *distance = scale;